/*
 * @Author: 郝奔 1425466221@qq.com
 * @Date: 2024-11-22 09:21:08
 * @LastEditors: 郝奔 1425466221@qq.com
 * @LastEditTime: 2024-12-26 11:00:34
 * @FilePath: /HG-dqbasic_open_platform/src/framework/api/dict/index.ts
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import { AxiosPromise } from 'axios';
import { ResultDataList, PageParms } from '@/framework/api/common/index';
import {
  DictQuery,
  DictPageResult,
  DictTypeForm,
  DictItemQuery,
  DictItemPageResult,
  DictItemForm, Dict
} from './types';


export function page(params: PageParms<Dict>): Promise<ResultDataList<Dict>> {
  return request({
    url: cloud.dqBasic + '/dictType/page',
    method: 'get',
    params
  })
}


/**
 * 获取字典类型分页列表
 *
 * @param queryParams
 */
export function listDictTypePages(
  queryParams: DictQuery
): AxiosPromise<DictPageResult> {
  return request({
    url: '/api/v1/dict/types/pages',
    method: 'get',
    params: queryParams
  });
}

/**
 * 获取字典类型表单数据
 *
 * @param id
 */
export function getDictTypeForm(id: number): AxiosPromise<DictTypeForm> {
  return request({
    url: '/api/v1/dict/types/' + id + '/form',
    method: 'get'
  });
}
/**
 * 获取字典类型的数据项
 *
 * @param typeCode 字典类型编码
 */
export function getDictionaries(typeCode: string): AxiosPromise<OptionType[]> {
  return request({
    url: '/api/v1/dict/types/' + typeCode + '/items',
    method: 'get'
  });
}

/**
 * 获取字典项分页列表
 */
export function listDictItemPages(
  queryParams: DictItemQuery
): AxiosPromise<DictItemPageResult> {
  return request({
    url: '/api/v1/dict/items/pages',
    method: 'get',
    params: queryParams
  });
}

/**
 * 获取字典数据项表单数据
 *
 * @param id
 */
export function getDictItemData(id: number): AxiosPromise<DictItemForm> {
  return request({
    url: '/api/v1/dict/items/' + id + '/form',
    method: 'get'
  });
}